<template>
  <div class="app-container">
    <search-box
      :fields="searchFeilds"
      @search="handleSearch"
      @add="handleAdd"
    />


    <SearchResult
      uid="contactInfo"
      ref="searchResult"
      :params="params"
      :ignoreCommand="ignoreCommand"
    >
      <el-table-column label="用户名" align="left">
        <template slot-scope="{row}">
          <span>{{ row.userName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="公司名称" align="center">
        <template slot-scope="{row}">
          <span>{{ row.companyName }}</span>
        </template>
      </el-table-column>
      <el-table-column label="联系电话" align="center">
        <template slot-scope="{row}">
          <span>{{ row.contactTelephone }}</span>
        </template>
      </el-table-column>
      <el-table-column label="邮箱" align="center">
        <template slot-scope="{row}">
          <span>{{ row.emailAddress }}</span>
        </template>
      </el-table-column>

      <el-table-column label="是否阅读" align="center">
        <template slot-scope="{row}">
          <span>{{ row.isRead === 1 ? '是' : '否' }}</span>
        </template>
      </el-table-column>

      <el-table-column label="创建时间" align="center">
        <template slot-scope="{row}">
          <span>{{ row.createDate }}</span>
        </template>
      </el-table-column>
    </SearchResult>
  </div>
</template>
<script>
import SearchBox from '@/components/SearchBox';
import SearchResult from '@/components/SearchResult';
import { isEnableOptions } from '@/utils/config';

export default {
  name: 'contact-info',
  components: { SearchBox, SearchResult },
  data() {
    return {
      searchFeilds: [
        { name: 'UserName', label: '用户姓名', type: 'text' },
        { name: 'CompanyName', label: '公司名称', type: 'text' },
        { name: 'ContactTelephone', label: '联系电话', type: 'text' },
        { name: 'IsRead', label: '是否阅读', type: 'list', options: isEnableOptions }
      ],
      ignoreCommand: ['detail'],
      params: {}
    };
  },

  methods: {
    // 搜索
    handleSearch(data) {
      if (data === void 0) data = {};

      this.params = data;
      this.$refs['searchResult'].getData(data);
    },

    // 添加
    handleAdd() {
      this.$refs['searchResult'].handleAdd();
    }
  }
}
</script>
